package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkSpaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * PROJECT_NAME: sky-take-out
 * NAME: WorkSpaceController
 * USER: zhang
 * DATE: 2023/6/9
 * DESCRIPTION :B端-工作台表现层
 */
@Slf4j
@RestController
@Api(tags = "B端-工作台表现层")
@RequestMapping("admin/workspace")
public class WorkSpaceController {
    @Resource
    private WorkSpaceService workSpaceService;

    /**
     * 查询今日运营数据
     * @return 全局通用返回信息Bean(businessDataVO)
     */
    @ApiOperation("B端-查询今日运营数据")
    @GetMapping("/businessData")
    public Result<BusinessDataVO> selectBusinessData(){
        //获取当天开始时间/结束时间
        LocalDateTime startTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        LocalDateTime endTime = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
        BusinessDataVO businessDataVO = workSpaceService.selectBusinessData(startTime,endTime);
        return Result.success(businessDataVO);
    }

    /**
     * 查询订单管理数据
     * @return 全局通用返回信息Bean(OrderOverViewVO)
     */
    @ApiOperation("B端-查询订单管理数据")
    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> selectOverviewOrders(){
        OrderOverViewVO orderOverViewVO = workSpaceService.selectOverviewOrders();
        return Result.success(orderOverViewVO);
    }

    /**
     * 查询菜品总览
     * @return 全局通用返回信息Bean(DishOverViewVO)
     */
    @ApiOperation("B端-查询菜品总览")
    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> selectDishOverViews(){
        DishOverViewVO dishOverViewVO = workSpaceService.selectDishOverViews();
        return Result.success(dishOverViewVO);
    }

    /**
     * 查询套餐总览
     * @return 全局通用返回信息Bean(DishOverViewVO)
     */
    @ApiOperation("B端-查询套餐总览")
    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> selectOverviewSetmeals(){
        SetmealOverViewVO setmealOverViewVO =  workSpaceService.selectOverviewSetmeals();
        return Result.success(setmealOverViewVO);
    }
}
